#include "DRVE.h"
void DRVE_init()
{
	pwm_init(PWMA_CH1P_P60,10000, 0);
	pwm_init(PWMA_CH2P_P62,10000, 0);
	pwm_init(PWMA_CH3P_P64,10000, 0);
	pwm_init(PWMA_CH4P_P66,10000, 0);
}
void DRVE_update(int PWM1,int PWM2)
{
	if(PWM1 > 0)
	{
		pwm_duty(PWMA_CH1P_P60, 10000);
		pwm_duty(PWMA_CH2P_P62, PWM1);
	}
	else
	{
        PWM1 = -PWM1;
		pwm_duty(PWMA_CH1P_P60, PWM1);
		pwm_duty(PWMA_CH2P_P62, 0);
	}
	if(PWM2 >= 0)
	{
		pwm_duty(PWMA_CH3P_P64, 0);
		pwm_duty(PWMA_CH4P_P66, PWM2);
	}
	else
	{
        PWM2 = -PWM2;
		pwm_duty(PWMA_CH3P_P64, PWM2);
		pwm_duty(PWMA_CH4P_P66, 10000);
	}

}